#include <iostream>
#include <vector>
using namespace std;

class Solution2 {
public:
    bool isPd(string B)
    {
        string tmp = B;
        reverse(tmp.begin(), tmp.end());
        return B == tmp;
    }

    int getLongestPalindrome(string A) {
        int n = A.size();
        if (n <= 2)
            return n;
        for (int i = n - 1; i >= 2; --i)
        {
            int left = 0, right = i;
            while (right < n)
            {
                if (isPd(A.substr(left, right - left + 1)))
                    return right - left + 1;
                ++right;
                ++left;
            }
        }
        return 2;
    }
};

class Solution {
public:
    int pivotIndex(vector<int>& nums) {
        int n = nums.size();
        vector<int> f(n), g(n);

        for (int i = 1; i < n; ++i)
            f[i] = f[i - 1] + nums[i - 1];
        for (int i = n - 2; i >= 0; --i)
            g[i] = g[i + 1] + nums[i + 1];

        for (int i = 0; i < n; ++i)
            if (f[i] == g[i])
                return i;
        return -1;
    }
};

int main()
{
    Solution();
	return 0;
}